home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1171 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: engnews2.Eng.Sun.COM!usenet
  2. From: nitin@more.eng.sun.com (Nitin More [CONTRACTOR])
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Creating a pointer to a function "void (*ptrFunction)()"  inside a class
  5. Date: 09 Jan 1996 18:32:42 GMT
  6. Organization: SunSoft
  7. Message-ID: <NITIN.96Jan9103242@more.eng.sun.com>
  8. References: <30ECA10F.3D99@ifu.net> <NITIN.96Jan5125830@more.eng.sun.com>
  9.     <4crquj$7t1@lib108.its.rpi.edu>
  10. NNTP-Posting-Host: more.eng.sun.com
  11. In-reply-to: floydb1@lib108.its.rpi.edu's message of 8 Jan 1996 14:22:59 -0500
  12.  
  13. In article <4crquj$7t1@lib108.its.rpi.edu> floydb1@lib108.its.rpi.edu (Barry B Floyd) writes:
  14.  
  15. > From: floydb1@lib108.its.rpi.edu (Barry B Floyd)
  16. > Newsgroups: comp.lang.c++
  17. > Date: 8 Jan 1996 14:22:59 -0500
  18. > Organization: Rensselaer Polytechnic Institute, Troy, NY.
  19.  
  20. [original message deleted]
  21.  
  22. > Try:
  23. >     class BaseClass
  24. >     {
  25. >         ...                 // other stuff
  26. >     virtual    int Function ( int, int ) = 0 ;  // pure virtual fn()
  27. >         ...                 // other stuff
  28. >     }
  29. >     class DerivedClass : BaseClass
  30. >     {
  31. >         ...                 // other stuff
  32. >         int Function ( int, int )      { // your code    } ;
  33. >         ...                 // other stuff
  34. >     }
  35. [text deleted]
  36.  
  37. > ps
  38. > note: "Function ( int, int )" remains virtual in DerivedClass,
  39. > even though the keyword "virtual" is not included in the declaration.
  40. > Thus, I believe "class DerivedDerivedClass : DerivedClass" must provide
  41. > a "Function ( int, int )" as well.
  42.  
  43.  
  44. I believe the last paragraph is wrong.  Somebody please correct me if I am
  45. wrong. 
  46.  
  47. (1) The "Function ( int, int )" *does not* remain virtual in DerivedClass
  48.     unless the keyword "virtual" is included in the declaration.
  49.  
  50. (2) The "class DerivedDerivedClass : DerivedClass" *does not* have to provide
  51.     a "Function ( int, int )" as well as long as one of its derived classes
  52.     has provided definition for the pure virtual function.
  53.  
  54. -Nitin
  55.  
  56. -- 
  57. ----------------------------------------------------------------------
  58. Nitin More                                                         
  59. SunSoft, Bldg 16  Off: (415) 786 7109                                 
  60. Menlo Park, CA    Fax: (415) 786 7957   e-mail: nitin@more.eng.sun.com
  61. ----------------------------------------------------------------------
  62.